package model;

import java.io.Serializable;

public class CinemaHall implements Serializable {
    private static final long serialVersionUID = 1L;
    private String name;
    private int rows;
    private int cols;
    private Seat[][] seats;

    public CinemaHall(String name, int rows, int cols) {
        this.name = name;
        this.rows = rows;
        this.cols = cols;
        initSeats();
    }

    private void initSeats() {
        seats = new Seat[rows][cols];
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                seats[i][j] = new Seat(i + 1, j + 1, false);
            }
        }
    }

    // 获取空闲座位数
    public int getAvailableSeats() {
        int count = 0;
        for (Seat[] row : seats) {
            for (Seat seat : row) {
                if (!seat.isSold()) count++;
            }
        }
        return count;
    }

    // Getter和Setter
    public String getName() { return name; }
    public int getRows() { return rows; }
    public int getCols() { return cols; }
    public Seat[][] getSeats() { return seats; }
    public int getTotalSeats() { return rows * cols; }
}